package com.example.mqltest.controler;

import com.example.mqltest.Dto.DeleteStudentsDTO;
import com.example.mqltest.entity.Result;
import com.example.mqltest.entity.Student;
import com.example.mqltest.entity.Teacher;
import com.example.mqltest.entity.Work;
import com.example.mqltest.service.TeacherService;
import com.example.mqltest.service.serviceImp.CourseServiceImp;
import com.example.mqltest.service.serviceImp.StudentServiceImp;
import com.example.mqltest.service.serviceImp.TeacherServiceImp;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("teacher")
public class TeacherController {

    @Autowired
    private TeacherService teacherService;

    @Autowired
    StudentServiceImp studentService;

    @Autowired
    CourseServiceImp courseService;

    @PostMapping("/register")
    public Result register(@RequestBody Teacher teacher){
        return teacherService.register(teacher);
    }


    //删除学生
    @GetMapping("/deleteStudent")
    public Result deleteStudent(@Param("code") String code, @Param("studentId") String studentId) {
       return teacherService.deleteStudent( code, studentId );
    }

    //删除课堂
    @GetMapping("/deleteCourse")
    public Result deleteCourse(@Param("code") String code){
        return teacherService.deleteCourse(code);
    }
    //发布作业
    @PostMapping("/addWork")
    public Result addWork(@RequestBody Work work){
        return teacherService.addWork(work);
    }

    //批量删除学生
    @PostMapping("/deleteCheckedStudent")
    public Result deleteCheckedStudent(@RequestBody DeleteStudentsDTO deleteStudentsDTO){
        return teacherService.deleteCheckedStudent( deleteStudentsDTO );
    }

    //批改作业
    @GetMapping("correctWork")
    public Result correctWork(@Param( "workId" )int workId,@Param("studentId")String studentId,@Param("grade")int grade){
        return teacherService.correctWork(workId,studentId,grade);
    }

    //老师加入课堂
    @GetMapping("/joinCourse")
    public Result joinCourse(@Param( "code" )String code,@Param( "teacherId" )String teacherId){
        return teacherService.joinCourse(code,teacherId);
    }

}
